import request from "@/utils/request";

export default {
  getProductList(searchModel) {
    return request({
      url: "/product/list",
      method: "get",
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        goodsName: searchModel.goodsName,
        warehouseName: searchModel.warehouseName,
        goodsTypeId: searchModel.goodsTypeId,
      },
    });
  },

  addProductr(product) {
    return request({
      url: "/product",
      method: "post",
      data: product,
    });
  },

  getproductById(id) {
    return request({
      url: `/product/${id}`,
      method: "get",
    });
  },

  saveProductr(product) {
    if (product.id == null && product.id == undefined) {
      return this.addProductr(product);
    }
    return this.updateProduct(product);
  },

  updateProduct(product) {
    return request({
      url: `/product`,
      method: "put",
      data: product,
    });
  },

  deleteProductById(id, qz_token) {
    return request({
      url: `/product/${id}`,
      method: "delete",
      data: qz_token,
    });
  },

  // 获取所有名称
  selseAllName() {
    return request({
      url: `/product/select`,
      method: "get",
    });
  },

  // 调拨库存，根据调出仓库获取库存商品,
  getProductByWarehouse(searchModel) {
    return request({
      url: `/product/getProductByWarehouse`,
      method: "get",
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        goodsName: searchModel.goodsName,
        warehouseId: searchModel.warehouseId,
        serialNumber: searchModel.serialNumber,
      },
    });
  },

  // DownlaodProductList:
  //   "http://localhost:9999/sys/inventory/getAllProductDangQi",
  DownlaodProductList:
    "http://154.8.182.144:9999/sys/inventory/getAllProductDangQi",
  // DownlaodProductList:
  // "http://www.quzhi.org.cn:9999/sys/inventory/getAllProductDangQi",
};
